using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms; 

namespace CommandPatternApp 
{
    public class CmdToolButton : ToolStripButton
    {
        private BaseCmd _command;

        public CmdToolButton()
            : base()
        {
            this.Click += new EventHandler(ButtonClicked);
            _command = null;
        }

        public BaseCmd Command
        {
            get { return _command; }
            set { _command = value; }
        }

        private void ButtonClicked(object sender, EventArgs args)
        {
            if (_command != null) _command.Execute();
        }
    }
}
